package com.icss.daos;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.icss.beans.ContactsGroupVO;
import com.icss.beans.LeaveVO;

public class LeaveDao {
	
	
	Dao dao=null;
	
	//新建请假
    public void insertLeave(String sql){
    	dao=new Dao();
    	boolean flag=dao.execute(sql);
    	if(flag==true){
        System.out.println(" 		请假申请成功！");
    		
    	}else{System.out.println("请假操作数据库失败");}
    	
    }
	public List<LeaveVO> selectLeave(String sql){
		List<LeaveVO> list=new ArrayList<LeaveVO>();
		dao=new Dao();
		
		ResultSet rs=dao.query(sql);
		try {
			while(rs.next()){
				LeaveVO vo=new LeaveVO();
				vo.setLeaveId(rs.getInt("leaveId"));
				vo.setLeavePersonName(rs.getString("leaveName"));
				vo.setLeaveReason(rs.getString("leaveReason"));
				vo.setBeginTime(rs.getDate("beginTime"));
				vo.setEndTime(rs.getDate("endTime"));
				vo.setShenpiPerson(rs.getString("shenpiPerson"));
				vo.setLeaveState(rs.getInt("state"));
				System.out.println("请假记录不为空");
				list.add(vo);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return list;
	}
	public void editLeave(String sql){
		dao=new Dao();
		boolean flag=dao.execute(sql);
		if(flag==true){
			
			System.out.println("请假状态已改变");
		}else{System.out.println("请假状态改变失败");}
		
	}
}
